#pragma once
#include "creature.h"

/*狼，移动速度和搜索范围均强于羊，移动到羊的位置即捕猎完成可以吃掉羊,后续考虑加入战斗规则*/
class Wolf : public Creature
{
public:
	Wolf();
	Wolf(int name);
	Wolf(int name, int x, int y, Flag flag);
	void choose_target_race(int mode);
	void record(Creature &c);
};

Wolf::Wolf() {}

Wolf::Wolf(int name)
{
	m_flag = {1, 0, 1, 0, 0, 20, 100, 200, 1, 1};
	m_name = name;
	m_age = rand() % m_flag.age_up;												 /*年龄在上限内随机生成*/
	m_hp = m_flag.hp_up / 2 + (rand() % (m_flag.hp_up / 2 + 1));				 /*生命值在上限一半到上限内生成*/
	m_hunger = m_flag.hunger_full / 2 + (rand() % (m_flag.hunger_full / 2 + 1)); /*饥饿值在饱一半到全饱内生成*/
	m_flag.gender = 1 + (rand() % 2);
	m_position = {rand() % 50, rand() % 50};
}

Wolf::Wolf(int name, int x, int y, Flag flag)
{
	m_flag = flag; /*先把标签赋给新生物，确定种族和上限，其他的之后覆盖*/
	/*创建一个生物，随机生成数值,x和y坐标固定*/
	m_position.x = x;
	m_position.y = y;
	m_name = name;
	m_age = 1;													 /*新生物的年龄为1*/
	m_hp = m_flag.hp_up / 2 + (rand() % (m_flag.hp_up / 2 + 1)); /*生命值在上限一半到上限内生成*/
	m_hunger = m_flag.hunger_full / 4;							 /*饥饿值为饱/4，需低于繁衍线避免回交*/
	m_flag.gender = 1 + (rand() % 2);
}

/*记录狩猎事件,只有狼有*/
void Wolf::record(Creature &c)
{
	nature.events[nature.temp_events] = new Events(nature.time_past, m_position, m_name, m_flag.race);
	nature.events[nature.temp_events]->get(c);
	nature.temp_events++;
	nature.num.events++;
}

void Wolf::choose_target_race(int mode)
{
	switch (mode)
	{
	case 1:
		m_target.race = nature.sheep;
		m_target.num = &nature.num.sheep;
		break;
	case 2:
		m_target.race = nature.wolf;
		m_target.num = &nature.num.wolf;
		break;
	default:
		break;
	}
}
